﻿/******************************************************************************
 *  All Rights Reserved , Copyright (C) 2012 , EricHu. 
 *  作    者： EricHu
 *  创建时间： 2012-7-20 16:35:01
 ******************************************************************************/
using System.Data;
using System.ServiceModel;

namespace RDIFramework.IService
{
    using RDIFramework.BusinessEntity;
    using RDIFramework.Utilities;

    /// <summary>
    /// IUserService
    /// 服务层接口
    /// 
    /// 修改纪录
    /// 
    ///		2012-03-02 版本：1.0 EricHu 创建文件。
    ///		
    /// 版本：1.0
    /// 
    /// <author>
    ///		<name>EricHu</name>
    ///		<date>2012-03-02</date>
    /// </author> 
    /// </summary>
    [ServiceContract]
    public interface IUserService
    {
        /// <summary>
        /// <c>用户名</c>是否重复
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="fieldNames">用户名</param>
        /// <param name="fieldValues">用户名</param>
        /// <returns>已存在</returns>
        [OperationContract]
        bool Exists(UserInfo userInfo, string[] fieldNames, object[] fieldValues);

        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="userEntity">用户实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        [OperationContract]
        string AddUser(UserInfo userInfo, PiUserEntity userEntity, out string statusCode, out string statusMessage);

        /// <summary>
        /// 按<c>部门</c>获取部门用户
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="departmentId">部门主键</param>
        /// <param name="containChildren">含子部门</param>
        /// <returns>数据表</returns>
        [OperationContract]
        DataTable GetDTByDepartment(UserInfo userInfo, string departmentId, bool containChildren);

        /// <summary>
        /// 获取用户实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>实体</returns>
        [OperationContract]
        PiUserEntity GetEntity(UserInfo userInfo, string id);

        /// <summary>
        /// 获得用户列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        [OperationContract]
        DataTable GetDT(UserInfo userInfo);
         
        /// <summary>
        /// 获取用户分页列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="recordCount">所有用户数</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="pageSize">分页大小（默认20条）</param>
        /// <param name="whereConditional">条件表达式</param>
        /// <param name="order">排序字段</param>
        /// <returns>数据表</returns>
        [OperationContract]
        DataTable GetDTByPage(UserInfo userInfo, out int recordCount, int pageIndex = 1, int pageSize = 20, string whereConditional = "", string order = "");

        /// <summary>
        /// 按主键获取用户
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>数据表</returns>
        [OperationContract]
        DataTable GetDTByIds(UserInfo userInfo, string[] ids);

        /// <summary>
        /// 按角色获取用户
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="roleId">角色主键</param>
        /// <returns>数据表</returns>
        [OperationContract]
        DataTable GetDTByRole(UserInfo userInfo, string roleId);

        /// <summary>
        /// 查询用户列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userName">用户名</param>
        /// <param name="auditStates">用户状态</param>
        /// <param name="roleIds">角色主键</param>
        /// <returns>数据表</returns>
        [OperationContract]
        DataTable Search(UserInfo userInfo, string userName, string auditStates, string[] roleIds);

        /// <summary>
        /// 设置用户状态
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <param name="auditStates">审核状态</param>
        /// <returns>影响行数</returns>
        [OperationContract]
        int SetUserAuditStates(UserInfo userInfo, string[] ids, AuditStatus auditStatus);

        /// <summary>
        /// 设置用户的默认角色
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <param name="roleId">角色主键</param>
        /// <returns>影响的行数</returns>
        [OperationContract]
        int SetDefaultRole(UserInfo userInfo, string userId, string roleId);

        /// <summary>
        /// 批量设置用户的默认角色
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userIds">用户主键</param>
        /// <param name="roleId">角色主键</param>
        /// <returns>影响的行数</returns>
        [OperationContract]
        int BatchSetDefaultRole(UserInfo userInfo, string[] userIds, string roleId);

        /// <summary>
        /// 单个删除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主键</param>
        /// <returns>影响行数</returns>
        [OperationContract]
        int Delete(UserInfo userInfo, string id);

        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        [OperationContract]
        int BatchDelete(UserInfo userInfo, string[] ids);

        /// <summary>
        /// 批量打删除标志
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        [OperationContract]
        int SetDeleted(UserInfo userInfo, string[] ids);

        /// <summary>
        /// 获取用户类型
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <returns>数据表</returns>
        [OperationContract]
        DataTable GetRoleDT(UserInfo userInfo);

        /// <summary>
        /// 用户是否在某个角色里
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <param name="roleCode">角色编号</param>
        /// <returns>存在</returns>
        [OperationContract]
        bool UserInRole(UserInfo userInfo, string userId, string roleCode);

        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="userInfo">用户信息</param>
        /// <param name="userEntity">用户实体</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>影响行数</returns>
        [OperationContract]
        int UpdateUser(UserInfo userInfo, PiUserEntity userEntity, out string statusCode, out string statusMessage);

        /// <summary>
        /// 获取员工角色列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="staffId">员工主键</param>
        /// <returns>主键数组</returns>
        [OperationContract]
        string[] GetUserRoleIds(UserInfo userInfo, string userId);

        /// <summary>
        /// 批量加入到员工
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="staffId">员工主键</param>
        /// <param name="addToRoleIds">加入角色主键集</param>
        /// <returns>影响的行数</returns>
        [OperationContract]
        int AddUserToRole(UserInfo userInfo, string userId, string[] addToRoleIds);

        /// <summary>
        /// 批量移出角色
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="staffId">员工主键</param>
        /// <param name="removeRoleIds">移出角色主键集</param>
        /// <returns>影响的行数</returns>
        [OperationContract]
        int RemoveUserFromRole(UserInfo userInfo, string userId, string[] removeRoleIds);

        /// <summary>
        /// 批量保存
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="dataTable">数据表</param>
        /// <returns>影响行数</returns>
        [OperationContract]
        int BatchSave(UserInfo userInfo, DataTable dataTable);

        /// <summary>
        /// 获得用户的组织机构兼职情况
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <returns>数据表</returns>
        [OperationContract]
        DataTable GetUserOrganizeDT(UserInfo userInfo, string userId);

        /// <summary>
        /// 用户帐户添加到组织机构
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userOrganizeEntity">用户组织关系</param>
        /// <param name="statusCode">状态码</param>
        /// <param name="statusMessage">状态信息</param>
        /// <returns>主键</returns>
        [OperationContract]
        string AddUserToOrganize(UserInfo userInfo,PiUserOrganizeEntity userOrganizeEntity, out string statusCode, out string statusMessage);

        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主键数组</param>
        /// <returns>影响行数</returns>
        [OperationContract]
        int BatchDeleteUserOrganize(UserInfo userInfo, string[] ids);

        /// <summary>
        /// 清除用户归属的角色
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <returns>影响行数</returns>
        [OperationContract]
        int ClearUserRole(UserInfo userInfo, string userId);
     }
}
